// 隐私政策页面
const agreementConfig = require('../../utils/agreement-config');

Page({
  data: {
    policy: {},
  },
  
  onLoad() {
    // 设置导航栏标题
    wx.setNavigationBarTitle({
      title: '隐私政策'
    });
    
    // 优先从缓存中获取隐私政策内容，提高加载速度
    try {
      const cachedPolicy = wx.getStorageSync('privacyPolicy');
      if (cachedPolicy) {
        this.setData({
          policy: cachedPolicy
        });
      } else {
        // 如果缓存中不存在，则从配置文件获取
        this.setData({
          policy: agreementConfig.privacyPolicy
        });
      }
    } catch (e) {
      // 如果获取缓存失败，则从配置文件获取
      this.setData({
        policy: agreementConfig.privacyPolicy
      });
    }
  },
  
  /**
   * 页面显示
   */
  onShow() {
    // 页面显示时无延迟立即渲染
    wx.setPageStyle({
      animated: false
    });
  },
  
  /**
   * 页面分享
   */
  onShareAppMessage() {
    return {
      title: '星途小程序隐私政策',
      path: '/pages/agreement/privacy-policy'
    };
  }
}); 